--编写者：alt
--功能介绍：踏水和无视碰撞
--使用方法：直接复制到对应位置 调用fn(player, true) fn(player, false) 开启或者关闭
local function collidesDirty(inst, get)
    if get then
        inst.Physics:ClearCollisionMask()
        inst.Physics:CollidesWith(COLLISION.GROUND)
    else
        inst.Physics:CollidesWith(COLLISION.OBSTACLES)
        inst.Physics:CollidesWith(COLLISION.WORLD)
        inst.Physics:CollidesWith(COLLISION.SMALLOBSTACLES)
        inst.Physics:CollidesWith(COLLISION.CHARACTERS)
        inst.Physics:CollidesWith(COLLISION.GIANTS)

        inst.Physics:CollidesWith(COLLISION.GROUND)
        --inst.Physics:ClearCollidesWith(COLLISION.GROUND)
    end
end
local function OnCollide(inst, other)
    --print("OnCollide", inst, other)
    collidesDirty(inst, true)
end
local function fn(inst, get)
    if get then
        --inst.DynamicShadow:Enable(false)
        inst.components.locomotor:SetAllowPlatformHopping(false)
        if inst.components.drownable then
            inst.components.drownable.enabled = false
        end
        if inst.Physics then
            collidesDirty(inst, true)
            inst.Physics:SetCollisionCallback(OnCollide)
        end
    else
        --inst.DynamicShadow:Enable(true)
        inst.components.locomotor:SetAllowPlatformHopping(true)
        if inst.components.drownable then
            inst.components.drownable.enabled = true
        end
        if inst.Physics then
            collidesDirty(inst, false)
            inst.Physics:SetCollisionCallback(nil)
        end
    end
end
